<template>
  <div class="app-container">
    <el-dialog title="关联PLM文件" :visible="openPLMFile" v-loading="dialogPLMLoading" @close="closePLMOpen" width="1200px"  :close-on-click-modal="false" :close-on-press-escape="false"
    append-to-body>
    <el-form :model="queryParamsPlm" ref="queryParamsPlm" size="small"  :inline="true" label-width="100px">
      <el-form-item label="PLM节点名称"  prop="workName">
        <el-input v-model.trim="queryParamsPlm.workName" @change="handleQueryPLM"  placeholder="请输入项目编码" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="PLM文件名称"  prop="fileName">
        <el-input v-model.trim="queryParamsPlm.fileName" @change="handleQueryPLM" placeholder="请输入产品名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search"   @click="handleQueryPLM">搜索</el-button>
        <el-button icon="el-icon-refresh"  @click="resetQueryPLM('openPLMFile')">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table border  :data="plmList" :border="false"  @selection-change="handleSelectionChange" header-cell-class-name="table_header_row">
      <el-table-column type="selection" width="55" />
      <el-table-column label="节点名称" align="left" prop="WorkName"/>
      <el-table-column label="文件名称" align="left" prop="FileName"/>
       
    </el-table>
    <span slot="footer" class="dialog-footer" > 
      <el-button  @click="closePLMOpen">取 消</el-button>
      <el-button type="primary" @click="handleSure">提 交</el-button>
    </span>
  </el-dialog> 

  </div>
</template>

<script>

import {queryPLMFile,bindPLMFile}  from "@/api/projectManage/task";


export default {
  name: "BindPLMFile",
 
  data() {
    return {
       //关联PLM文件
      openPLMFile:false,
      dialogPLMLoading:false,
      plmList:[],
      queryParamsPlm:{},
      //选择的PLM文件列表
      selectPLMFiles:[],
      //当前行
      currRow:{},  
    };
  },
 
 
  methods: {

    //选择的PLM文件
    handleSelectionChange(val){
        this.selectPLMFiles = val;
    },

    resetQueryPLM(formName){
      this.$refs[formName].resetFields();
    },


    //绑定PLM文件
    handleSure(){

      this.$modal.loading("请稍候...");
      let param = {
        projectNodeMemberId:this.currRow.id,
        files:this.selectPLMFiles
      }
      bindPLMFile(param).then(response=>{
        this.$modal.closeLoading();
        this.closePLMOpen();
        this.getList();
        this.getListNum();

        this.queryParams.flag = 0;
      })  
    },

    //关联PLM文件
    open(row){
        this.currRow = row;
        this.openPLMFile = true;
        this.dialogPLMLoading = true;
        this.queryParamsPlm.projectNo = row.projectNo;
        queryPLMFile(this.queryParamsPlm).then(response=>{
          this.dialogPLMLoading = false;
          this.plmList = response.data;
        }).catch(error=>{
          this.dialogPLMLoading = false;
        })
    },

    handleQueryPLM(){
        this.dialogPLMLoading = true; 
        queryPLMFile(this.queryParamsPlm).then(response=>{
          this.dialogPLMLoading = false;
          this.plmList = response.data;
        }).catch(error=>{
          this.dialogPLMLoading = false;
        })
    },
 

    //关闭PLM文件选择 框
    closePLMOpen(){
      this.openPLMFile = false;
      this.plmList = [];
      this.currRow = {};
      this.selectPLMFiles = [];
      this.queryParamsPlm = {};
    },
 
  }
};
</script>
<style scoped>
.el-col {
  height: 60px;
}

.labelword ::v-deep .el-form-item__label {
  white-space: pre-line !important;
  line-height: 15px !important;
}

.el-table .danger-row {
  background: rgb(187, 179, 184);
}

.el-table .success-row {
  background: #00FF00;
}


::v-deep .table_header_row{
  background-color:#ffffff !important;

}
</style>
